package cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.service;

import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.entity.Conference;
import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.mapper.ConferenceMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 张烁瑜
 * @Date 2025/5/21 15:55
 */
@Service
public class ConferenceService {
    @Autowired
    private ConferenceMapper conferenceMapper;

    public String save(Conference conference) {
        if (conferenceMapper.save(conference)) {
            return "保存成功";
        }
        return "保存失败";
    }

    public String delete(Long conferenceId) {
        if (conferenceMapper.delete(conferenceId)) {
            return "删除成功";
        }
        return "删除失败";
    }

    public String update(Conference conference) {
        if (conferenceMapper.update(conference)) {
            return "更新成功";
        }
        return "更新失败";
    }

    public PageInfo<Conference> get(int pageNum, int pageSize, Conference conference){
        PageHelper.startPage(pageNum,pageSize);
        List<Conference> conferencesList  = conferenceMapper.get(conference);
        return PageInfo.of(conferencesList);
    }
}
